<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>房屋征收面积及补偿情况统计表</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="../css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="../css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="../css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="../css/animate.css" rel="stylesheet">
    <link href="../css/style.css?v=4.1.0" rel="stylesheet">

    <link rel="stylesheet" href="../css/element.css">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content">
        <div class="row">
            <div class="col-sm-3">
                <div class="ibox float-e-margins">
                    <div class="ibox-content mailbox-content">
                        <div id="project-group" class="file-manager">
                            <button @click="editer()" class="btn btn-block btn-primary">新建项目组</button>
                            <div class="space-25"></div>
                            <h5>项目组</h5>
                            <ul class="folder-list m-b-md" style="padding: 0;">
                                <li v-for="item in list">
                                    <a @click="open(item.id)" style="display: inline-block;width: calc(100% - 45px)">
                                        <i class="fa fa-group "></i>{{ item.name }}
                                    </a>
                                    <div class="pull-right" style="line-height: 28px;width: 45px;">
                                        <i @click="editer(item)" class="fa fa-edit " style="cursor: pointer;color: #1ab394;"></i>
                                        <i @click="remove(item.id)" class="fa fa-trash-o " style="cursor: pointer;color:#ed5565;"></i>
                                    </div>
                                </li>
                            </ul>
                            <div class="clearfix"></div>

                            <el-dialog
                                    title="项目组编辑"
                                    :visible.sync="dialogVisible">
                                <el-form :model="group" label-width="100px">
                                    <el-form-item
                                        label="项目组名称"
                                        prop="name"
                                        :rules="[
                                          { required: true, message: '名称不能为空'},
                                          { validator: unique}
                                        ]"
                                    >
                                        <el-input v-model="group.name"></el-input>
                                    </el-form-item>
                                    <el-form-item label="项目组说明">
                                        <el-input type="textarea" v-model="group.description"></el-input>
                                    </el-form-item>
                                </el-form>
                                <span slot="footer" class="dialog-footer">
                                    <el-button @click="dialogVisible = false">取 消</el-button>
                                    <el-button type="primary" @click="save">确 定</el-button>
                                </span>
                            </el-dialog>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-9 animated fadeInRight">
                <div class="mail-box-header">
                    <h2>组成员</h2>
                    <div class="mail-tools tooltip-demo m-t-md" style="text-align: right;">
                        <button class="btn btn-white btn-sm"><i class="fa fa-refresh"></i></button>
                        <button class="btn btn-primary btn-sm"><i class="fa fa-plus"></i></button>

                    </div>
                </div>
                <div class="mail-box">

                    <table class="table table-striped table-hover">
                        <tbody>
                        <tr>
                            <td class="client-avatar"><img alt="image" src="../img/portrait.png"> </td>
                            <td> 瑞安市海诚机械有限公司</td>
                            <td class="contact-type"><i class="glyphicon glyphicon-earphone"> </i>
                            </td>
                            <td> gravida@qq.com</td>
                            <td class="client-status" style="text-align: right;">
                                <button class="btn btn-primary btn-sm"><i class="fa fa-edit"></i> 编辑</button>
                                <button class="btn btn-danger btn-sm"><i class="fa fa-trash-o"></i> 删除</button>
                            </td>
                        </tr>

                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <!-- 全局js -->
    <script src="../js/jquery.min.js?v=2.1.4"></script>
    <script src="../js/bootstrap.min.js?v=3.3.6"></script>
    <!-- 自定义js -->
    <script src="../js/content.js?v=1.0.0"></script>
    <script src="../js/plugins/layer/layer.min.js"></script>

    <script src="../js/vue.js"></script>
    <script src="../js/element.js"></script>
    <script>

        new Vue({
            el: '#project-group',
            data: {
                dialogVisible: false,
                list: [
                    {id: 1, name: 'ABC'},
                    {id: 2, name: 'DEF'}
                ],
                group: {
                    id: undefined,
                    name: '',
                    description: ''
                }
            },
            created: function () {
                $.get("/api/project/list",function (data,status) {
                    console.log(data)
                });
            },
            methods: {
                unique: function(rule, value, callback) {
                    var isError = false;
                    for (var i = 0; i < this.list.length; i++){
                        if(value === this.list[i].name && this.group.id !== this.list[i].id) {
                            isError = true;
                            break;
                        }
                    }
                    if(isError)
                        callback(new Error('项目组名称已经存在'));
                    else
                        callback();
                },
                editer: function (data) {
                    if (data == undefined) {
                        this.group = {
                            id: undefined,
                            name: '',
                            description: ''
                        };
                    }else {
                        this.group = data;
                    }
                    this.dialogVisible = true;
                },
                save: function () {

                },
                remove: function (id) {
                    console.log(id)
                },
                open: function (id) {
                    console.log('open:',id)
                }
            }
        })
    </script>

</body>

</html>
